home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /* $Revision: 1.3 $ */
- /*
- * tulip - Turns root cursor into three-color tulip.
- * COMPILE: cc -o tulip tulip.c -lXext -lX11_s
- */
-
- #include <X11/Xlib.h>
- #include <X11/extensions/SGIMisc.h>
-
- /*
- * Basis for constructing a three color cursor:
- *
- * Cursor plane 0 is date ("foreground")
- * Cursor plane 1 is mask ("background")
- *
- * X server color display truth table:
- * mask(bit1) source(bit0) color
- * 0 0 transparent
- * 0 1 third color
- * 1 0 background
- * 1 1 foreground
- *
- * WARNING: Not all SGI hardware supports three-color cursors (ie,
- * early Personal IRIS models).
- */
-
- /*
- * Tulip 16x16 bitmaps (foreground and background) generated via bitmap.
- */
-
- #define tulip_fg_width 16
- #define tulip_fg_height 16
- static char tulip_fg_bits[] = {
- 0x00, 0x00, 0x04, 0x20, 0x5c, 0x3a, 0xf8, 0x1f, 0xf0, 0x0f, 0xe0, 0x07,
- 0xc0, 0x01, 0x80, 0x00, 0x80, 0x00, 0x9c, 0x1e, 0xbc, 0x1f, 0xf8, 0x0f,
- 0xb0, 0x06, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00};
-
- #define tulip_bg_width 16
- #define tulip_bg_height 16
- static char tulip_bg_bits[] = {
- 0x06, 0x60, 0x5e, 0x7a, 0xfe, 0x7f, 0xfc, 0x3f, 0xf8, 0x1f, 0xf0, 0x0f,
- 0xe0, 0x07, 0x40, 0x01, 0x5c, 0x1f, 0x62, 0x21, 0x42, 0x20, 0x04, 0x10,
- 0x48, 0x09, 0x70, 0x07, 0x40, 0x01, 0x40, 0x01};
-
- main()
- {
- Display *dpy;
- Window root;
- Pixmap fg_pixmap, bg_pixmap;
- Cursor cursor;
- XColor red, white, green;
- Status status;
- Colormap cmap;
- int dummy;
-
- dpy = XOpenDisplay(NULL);
- if (dpy == NULL) {
- fprintf(stderr, "tulip: could not open display\n");
- exit(1);
- }
- if (!XSGIMiscQueryExtension(dpy, &dummy, &dummy)) {
- fprintf(stderr, "tulip: SGI-SUNDRY-NONSTANDARD extension required\n");
- exit(1);
- }
- root = DefaultRootWindow(dpy);
- cmap = DefaultColormap(dpy, DefaultScreen(dpy));
- status = XParseColor(dpy, cmap, "orangered", &red);
- status = status && XParseColor(dpy, cmap, "white", &white);
- status = status && XParseColor(dpy, cmap, "darkgreen", &green);
- if (status == 0) {
- fprintf(stderr, "tulip: unable to parse colors\n");
- exit(1);
- }
- fg_pixmap = XCreateBitmapFromData(dpy, root, tulip_fg_bits,
- tulip_fg_width, tulip_bg_height);
- bg_pixmap = XCreateBitmapFromData(dpy, root, tulip_bg_bits,
- tulip_bg_width, tulip_bg_height);
- cursor = XCreatePixmapCursor(dpy, fg_pixmap, bg_pixmap, &red, &white,
- tulip_fg_width / 2, tulip_bg_height / 2);
- XSGIMiscSetThirdCursorColor(dpy, cursor, &green);
- XDefineCursor(dpy, root, cursor);
- XCloseDisplay(dpy);
- printf("to restore: xsetroot -cursor_name X_cursor -fg red -bg white\n");
- exit(0);
- }
-